package com.tanhua.demo;

import cn.hutool.core.io.FileUtil;
import com.tanhua.template.AipFaceTemplate;
import com.tanhua.template.OssTemplate;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

@SpringBootTest
@RunWith(SpringRunner.class)
public class SpringJunit {

    @Autowired
    private OssTemplate ossTemplate;

    @Autowired
    private AipFaceTemplate aipFaceTemplate;

    @Test
    public void test1() throws FileNotFoundException {

        String file = "D:\\图文\\壁纸\\cc.jpg";
        String url = ossTemplate.upload(file, new FileInputStream(file));
        System.out.println(url);

    }


    @Test
    public void test2() throws FileNotFoundException {

        String filename = "D:\\图文\\壁纸\\3.png";
        File file = new File(filename);
        byte[] bytes = FileUtil.readBytes(file);
        boolean flag = aipFaceTemplate.detect(bytes);
        System.out.println(flag);

    }
}
